Integrand size = 13, antiderivative size = 72 \[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx=\frac {a \left (a^2+3 b^2\right ) x}{2 \left (a^2+b^2\right )^2}-\frac {b^3 \log (b \cos (x)+a \sin (x))}{\left (a^2+b^2\right )^2}-\frac {(b+a \cot (x)) \sin ^2(x)}{2 \left (a^2+b^2\right )} \]
1/2*a*(a^2+3*b^2)*x/(a^2+b^2)^2-b^3*ln(b*cos(x)+a*sin(x))/(a^2+b^2)^2-1/2* (b+a*cot(x))*sin(x)^2/(a^2+b^2)
Result contains complex when optimal does not.
Time = 0.33 (sec) , antiderivative size = 94, normalized size of antiderivative = 1.31 \[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx=\frac {2 a^3 x+6 a b^2 x-4 i b^3 x+4 i b^3 \arctan (\tan (x))+b \left (a^2+b^2\right ) \cos (2 x)-2 b^3 \log \left ((b \cos (x)+a \sin (x))^2\right )-a^3 \sin (2 x)-a b^2 \sin (2 x)}{4 \left (a^2+b^2\right )^2} \]
(2*a^3*x + 6*a*b^2*x - (4*I)*b^3*x + (4*I)*b^3*ArcTan[Tan[x]] + b*(a^2 + b ^2)*Cos[2*x] - 2*b^3*Log[(b*Cos[x] + a*Sin[x])^2] - a^3*Sin[2*x] - a*b^2*S in[2*x])/(4*(a^2 + b^2)^2)
Time = 0.35 (sec) , antiderivative size = 136, normalized size of antiderivative = 1.89, number of steps used = 8, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.538, Rules used = {3042, 3987, 27, 496, 25, 657, 2009}
Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.
\(\displaystyle \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx\) |
\(\Big \downarrow \) 3042 |
\(\displaystyle \int \frac {1}{\sec \left (x-\frac {\pi }{2}\right )^2 \left (a-b \tan \left (x-\frac {\pi }{2}\right )\right )}dx\) |
\(\Big \downarrow \) 3987 |
\(\displaystyle -\frac {\int \frac {b^4}{(a+b \cot (x)) \left (\cot ^2(x) b^2+b^2\right )^2}d(b \cot (x))}{b}\) |
\(\Big \downarrow \) 27 |
\(\displaystyle -b^3 \int \frac {1}{(a+b \cot (x)) \left (\cot ^2(x) b^2+b^2\right )^2}d(b \cot (x))\) |
\(\Big \downarrow \) 496 |
\(\displaystyle -b^3 \left (\frac {a b \cot (x)+b^2}{2 b^2 \left (a^2+b^2\right ) \left (b^2 \cot ^2(x)+b^2\right )}-\frac {\int -\frac {a^2+b \cot (x) a+2 b^2}{(a+b \cot (x)) \left (\cot ^2(x) b^2+b^2\right )}d(b \cot (x))}{2 b^2 \left (a^2+b^2\right )}\right )\) |
\(\Big \downarrow \) 25 |
\(\displaystyle -b^3 \left (\frac {\int \frac {a^2+b \cot (x) a+2 b^2}{(a+b \cot (x)) \left (\cot ^2(x) b^2+b^2\right )}d(b \cot (x))}{2 b^2 \left (a^2+b^2\right )}+\frac {a b \cot (x)+b^2}{2 b^2 \left (a^2+b^2\right ) \left (b^2 \cot ^2(x)+b^2\right )}\right )\) |
\(\Big \downarrow \) 657 |
\(\displaystyle -b^3 \left (\frac {\int \left (\frac {2 b^2}{\left (a^2+b^2\right ) (a+b \cot (x))}+\frac {a^3+3 b^2 a-2 b^3 \cot (x)}{\left (a^2+b^2\right ) \left (\cot ^2(x) b^2+b^2\right )}\right )d(b \cot (x))}{2 b^2 \left (a^2+b^2\right )}+\frac {a b \cot (x)+b^2}{2 b^2 \left (a^2+b^2\right ) \left (b^2 \cot ^2(x)+b^2\right )}\right )\) |
\(\Big \downarrow \) 2009 |
\(\displaystyle -b^3 \left (\frac {\frac {a \left (a^2+3 b^2\right ) \arctan (\cot (x))}{b \left (a^2+b^2\right )}-\frac {b^2 \log \left (b^2 \cot ^2(x)+b^2\right )}{a^2+b^2}+\frac {2 b^2 \log (a+b \cot (x))}{a^2+b^2}}{2 b^2 \left (a^2+b^2\right )}+\frac {a b \cot (x)+b^2}{2 b^2 \left (a^2+b^2\right ) \left (b^2 \cot ^2(x)+b^2\right )}\right )\) |
-(b^3*((b^2 + a*b*Cot[x])/(2*b^2*(a^2 + b^2)*(b^2 + b^2*Cot[x]^2)) + ((a*( a^2 + 3*b^2)*ArcTan[Cot[x]])/(b*(a^2 + b^2)) + (2*b^2*Log[a + b*Cot[x]])/( a^2 + b^2) - (b^2*Log[b^2 + b^2*Cot[x]^2])/(a^2 + b^2))/(2*b^2*(a^2 + b^2) )))
3.1.15.3.1 Defintions of rubi rules used
Int[(a_)*(Fx_), x_Symbol] :> Simp[a Int[Fx, x], x] /; FreeQ[a, x] && !Ma tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, x]]
Int[((c_) + (d_.)*(x_))^(n_)*((a_) + (b_.)*(x_)^2)^(p_), x_Symbol] :> Simp[ (-(a*d + b*c*x))*(c + d*x)^(n + 1)*((a + b*x^2)^(p + 1)/(2*a*(p + 1)*(b*c^2 + a*d^2))), x] + Simp[1/(2*a*(p + 1)*(b*c^2 + a*d^2)) Int[(c + d*x)^n*(a + b*x^2)^(p + 1)*Simp[b*c^2*(2*p + 3) + a*d^2*(n + 2*p + 3) + b*c*d*(n + 2 *p + 4)*x, x], x], x] /; FreeQ[{a, b, c, d, n}, x] && LtQ[p, -1] && IntQuad raticQ[a, 0, b, c, d, n, p, x]
Int[(((d_.) + (e_.)*(x_))^(m_.)*((f_.) + (g_.)*(x_))^(n_.))/((a_) + (c_.)*( x_)^2), x_Symbol] :> Int[ExpandIntegrand[(d + e*x)^m*((f + g*x)^n/(a + c*x^ 2)), x], x] /; FreeQ[{a, c, d, e, f, g, m}, x] && IntegersQ[n]
Int[sec[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_ ), x_Symbol] :> Simp[1/(b*f) Subst[Int[(a + x)^n*(1 + x^2/b^2)^(m/2 - 1), x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, n}, x] && NeQ[a^2 + b^2, 0] && IntegerQ[m/2]
Time = 0.64 (sec) , antiderivative size = 97, normalized size of antiderivative = 1.35
method | result | size |
default | \(-\frac {b^{3} \ln \left (\tan \left (x \right ) a +b \right )}{\left (a^{2}+b^{2}\right )^{2}}+\frac {\frac {\left (-\frac {1}{2} a^{3}-\frac {1}{2} a \,b^{2}\right ) \tan \left (x \right )+\frac {a^{2} b}{2}+\frac {b^{3}}{2}}{\tan \left (x \right )^{2}+1}+\frac {b^{3} \ln \left (\tan \left (x \right )^{2}+1\right )}{2}+\frac {\left (a^{3}+3 a \,b^{2}\right ) \arctan \left (\tan \left (x \right )\right )}{2}}{\left (a^{2}+b^{2}\right )^{2}}\) | \(97\) |
risch | \(\frac {i x b}{2 i a b +a^{2}-b^{2}}+\frac {x a}{4 i a b +2 a^{2}-2 b^{2}}+\frac {i {\mathrm e}^{2 i x}}{8 i b +8 a}-\frac {i {\mathrm e}^{-2 i x}}{8 \left (-i b +a \right )}+\frac {2 i b^{3} x}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {b^{3} \ln \left ({\mathrm e}^{2 i x}+\frac {i b -a}{i b +a}\right )}{a^{4}+2 a^{2} b^{2}+b^{4}}\) | \(145\) |
-b^3/(a^2+b^2)^2*ln(tan(x)*a+b)+1/(a^2+b^2)^2*(((-1/2*a^3-1/2*a*b^2)*tan(x )+1/2*a^2*b+1/2*b^3)/(tan(x)^2+1)+1/2*b^3*ln(tan(x)^2+1)+1/2*(a^3+3*a*b^2) *arctan(tan(x)))
Time = 0.29 (sec) , antiderivative size = 94, normalized size of antiderivative = 1.31 \[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx=-\frac {b^{3} \log \left (2 \, a b \cos \left (x\right ) \sin \left (x\right ) - {\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + a^{2}\right ) - {\left (a^{2} b + b^{3}\right )} \cos \left (x\right )^{2} + {\left (a^{3} + a b^{2}\right )} \cos \left (x\right ) \sin \left (x\right ) - {\left (a^{3} + 3 \, a b^{2}\right )} x}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} \]
-1/2*(b^3*log(2*a*b*cos(x)*sin(x) - (a^2 - b^2)*cos(x)^2 + a^2) - (a^2*b + b^3)*cos(x)^2 + (a^3 + a*b^2)*cos(x)*sin(x) - (a^3 + 3*a*b^2)*x)/(a^4 + 2 *a^2*b^2 + b^4)
\[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx=\int \frac {\sin ^{2}{\left (x \right )}}{a + b \cot {\left (x \right )}}\, dx \]
Time = 0.31 (sec) , antiderivative size = 120, normalized size of antiderivative = 1.67 \[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx=-\frac {b^{3} \log \left (a \tan \left (x\right ) + b\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac {b^{3} \log \left (\tan \left (x\right )^{2} + 1\right )}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} + \frac {{\left (a^{3} + 3 \, a b^{2}\right )} x}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} - \frac {a \tan \left (x\right ) - b}{2 \, {\left ({\left (a^{2} + b^{2}\right )} \tan \left (x\right )^{2} + a^{2} + b^{2}\right )}} \]
-b^3*log(a*tan(x) + b)/(a^4 + 2*a^2*b^2 + b^4) + 1/2*b^3*log(tan(x)^2 + 1) /(a^4 + 2*a^2*b^2 + b^4) + 1/2*(a^3 + 3*a*b^2)*x/(a^4 + 2*a^2*b^2 + b^4) - 1/2*(a*tan(x) - b)/((a^2 + b^2)*tan(x)^2 + a^2 + b^2)
Leaf count of result is larger than twice the leaf count of optimal. 148 vs. \(2 (68) = 136\).
Time = 0.26 (sec) , antiderivative size = 148, normalized size of antiderivative = 2.06 \[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx=-\frac {a b^{3} \log \left ({\left | a \tan \left (x\right ) + b \right |}\right )}{a^{5} + 2 \, a^{3} b^{2} + a b^{4}} + \frac {b^{3} \log \left (\tan \left (x\right )^{2} + 1\right )}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} + \frac {{\left (a^{3} + 3 \, a b^{2}\right )} x}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} - \frac {b^{3} \tan \left (x\right )^{2} + a^{3} \tan \left (x\right ) + a b^{2} \tan \left (x\right ) - a^{2} b}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )} {\left (\tan \left (x\right )^{2} + 1\right )}} \]
-a*b^3*log(abs(a*tan(x) + b))/(a^5 + 2*a^3*b^2 + a*b^4) + 1/2*b^3*log(tan( x)^2 + 1)/(a^4 + 2*a^2*b^2 + b^4) + 1/2*(a^3 + 3*a*b^2)*x/(a^4 + 2*a^2*b^2 + b^4) - 1/2*(b^3*tan(x)^2 + a^3*tan(x) + a*b^2*tan(x) - a^2*b)/((a^4 + 2 *a^2*b^2 + b^4)*(tan(x)^2 + 1))
Time = 12.05 (sec) , antiderivative size = 126, normalized size of antiderivative = 1.75 \[ \int \frac {\sin ^2(x)}{a+b \cot (x)} \, dx={\cos \left (x\right )}^2\,\left (\frac {b}{2\,\left (a^2+b^2\right )}-\frac {a\,\mathrm {tan}\left (x\right )}{2\,\left (a^2+b^2\right )}\right )-\frac {b^3\,\ln \left (b+a\,\mathrm {tan}\left (x\right )\right )}{{\left (a^2+b^2\right )}^2}+\frac {\ln \left (\mathrm {tan}\left (x\right )-\mathrm {i}\right )\,\left (2\,b+a\,1{}\mathrm {i}\right )}{4\,\left (-a^2+a\,b\,2{}\mathrm {i}+b^2\right )}+\frac {\ln \left (\mathrm {tan}\left (x\right )+1{}\mathrm {i}\right )\,\left (a+b\,2{}\mathrm {i}\right )}{4\,\left (-a^2\,1{}\mathrm {i}+2\,a\,b+b^2\,1{}\mathrm {i}\right )} \]